<?php
namespace App\Admin\Extensions\Form;

use Dcat\Admin\Admin;
use Dcat\Admin\Form\Field\Map;

class TencentMap extends Map
{
    protected $view = 'form.map';

    public function __construct($column, $arguments)
    {
        $this->column['lat'] = (string) $column;
        $this->column['lng'] = (string) $arguments[0];
        $this->column['address'] = (string) $arguments[1];
        array_shift($arguments);
        array_shift($arguments);
        $this->label = $this->formatLabel($arguments);
        $this->tencent();
    }

    /**
     * Get assets required by this field.
     *
     * @return void
     */
    public static function requireAssets()
    {
        $keys = config('admin.map.keys');
//        $js1 = '//map.qq.com/api/js?v=2.exp&key='.($keys['tencent'] ?? env('TENCENT_MAP_API_KEY'));
        $js = '//map.qq.com/api/gljs?v=1.exp&key='.($keys['tencent'] ?? env('TENCENT_MAP_API_KEY')).'&libraries=service';
//        https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&libraries=service'
        Admin::js($js);
    }

}
